/**
 * @author zhangmin
 * @create 2022-08-23 18:58
 * 将数组中的奇数排到前面，偶数排到后面，奇数偶数内部保持相对顺序
 * 1、遍历两边分别取到奇数和偶数，
 * 2、用两个数组来分别存奇数和偶数
 * https://www.jianshu.com/p/d362fb227c9e
 */
public class Baidu0823 {
    public static void main(String[] args) {
        int[] nums=new int[]{2,3,4,5};
        int n=nums.length;
        int[] res1=new int[n],res2=new int[n];
        int p1=0,p2=0;
        for(int i=0;i<n;i++){
            if (nums[i]%2==0){
                res1[p1++]=nums[i];
            }else {
                res2[p2++]=nums[i];
            }
        }
        for (int i=0;i<p1;i++) {
            System.out.println(res1[i]+" ");
        }
        for (int i=0;i<p2;i++) {
            System.out.println(res2[i]+" ");
        }
    }
}
